﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
/// <summary>
/// Summary description for clsOtherDAL
/// </summary>
public class clsOtherDAL
{
    InstantNaukriDataContextDataContext objInstantNaukriDataContextDataContext = new InstantNaukriDataContextDataContext();
    public clsOtherDAL()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public List<IN_TB_OTHER> GetAllOtherinfo()
    {
        try
        {
            List<IN_TB_OTHER> objIN_TB_OTHER = new List<IN_TB_OTHER>();
            objIN_TB_OTHER = (from obj in objInstantNaukriDataContextDataContext.IN_TB_OTHERs
                              select obj).ToList();
            return objIN_TB_OTHER;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public IN_TB_OTHER GetOtherinfoById(int ID)
    {
        try
        {
            IN_TB_OTHER objIN_TB_OTHER = new IN_TB_OTHER();
            objIN_TB_OTHER = (from obj in objInstantNaukriDataContextDataContext.IN_TB_OTHERs
                              where obj.ID == ID
                              select obj).SingleOrDefault();
            return objIN_TB_OTHER;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public IN_TB_OTHER GetOtherinfoByUserId(int UserID)
    {
        try
        {
            IN_TB_OTHER objIN_TB_OTHER = new IN_TB_OTHER();
            objIN_TB_OTHER = (from obj in objInstantNaukriDataContextDataContext.IN_TB_OTHERs
                              where obj.USER_ID == UserID
                              select obj).SingleOrDefault();
            return objIN_TB_OTHER;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public int SaveLOtherInfo(IN_TB_OTHER objIN_TB_OTHER)
    {
        try
        {
            IN_TB_OTHER objIN_TB_OTHERD = new IN_TB_OTHER();
            objIN_TB_OTHERD = (from obj in objInstantNaukriDataContextDataContext.IN_TB_OTHERs
                               where obj.USER_ID == objIN_TB_OTHER.USER_ID
                               select obj).SingleOrDefault();
            if (objIN_TB_OTHERD != null)
            {
                objIN_TB_OTHERD.ID = objIN_TB_OTHER.ID;
                objIN_TB_OTHERD.DESIRED_JOB_TYPE = objIN_TB_OTHER.DESIRED_JOB_TYPE;
                objIN_TB_OTHERD.DESIRED_EMPOLOYMENT_TYPE = objIN_TB_OTHER.DESIRED_EMPOLOYMENT_TYPE;
                objIN_TB_OTHERD.WORK_PERMIT_LOCATION = objIN_TB_OTHER.WORK_PERMIT_LOCATION;
                objIN_TB_OTHERD.HAVE_VISA = objIN_TB_OTHER.HAVE_VISA;
                objIN_TB_OTHERD.VISA_TYPE = objIN_TB_OTHER.VISA_TYPE;
                objIN_TB_OTHERD.USER_ID = objIN_TB_OTHER.USER_ID;
                objIN_TB_OTHERD.CREATED_BY = objIN_TB_OTHER.CREATED_BY;
                objIN_TB_OTHERD.CREATED_ON = objIN_TB_OTHER.CREATED_ON;
                objIN_TB_OTHERD.MODIFIED_BY = objIN_TB_OTHER.MODIFIED_BY;
                objIN_TB_OTHERD.MODIFIED_ON = objIN_TB_OTHER.MODIFIED_ON;
                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_OTHERD.ID;
            }
            else
            {
                objInstantNaukriDataContextDataContext.IN_TB_OTHERs.InsertOnSubmit(objIN_TB_OTHER);
                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_OTHER.ID;
            }
        }
        catch (Exception)
        {

            throw;
        }
    }
}
